//
//  CommonCoinApi.hpp
//  Test
//
//  Created by xgc on 12/19/17.
//  Copyright © 2017 xgc. All rights reserved.
//

#ifndef CommonCoinApi_hpp
#define CommonCoinApi_hpp

#include "Netparams.hpp"
#include "BtSeed.hpp"
#include "BtWallet.hpp"

#include <vector>
#include <string>
#include <iostream>
#include <map>
#include <bitcoin/bitcoin.hpp>
#include "ChildNumber.hpp"
#include "Common.h"
#include "CreateSignTransactionParams.hpp"
#include "BtcCreateSignTransactionParams.hpp"
#include "BtcvoutForm.hpp"
#include "EthCreateSignTransactionParams.hpp"
#include "QtumCreateSignTransactionParams.hpp"

using namespace bc;
using namespace bc::wallet;
using namespace std;

class CommonCoinApi
{
public:
    
    /*
     获取助记词列表
     */
    vector<string> createAllCoinMnemonicCode();
    
    /*
     检查助记词列表
     */
    bool checkMnemonicCode(vector<string> words);
    
    /*
     根据 加密种子获取 解密后的私钥
     */
    string getPriKeyFromBtSeed(BtSeed btSeed, string password, NetParams netParams);
    
    /*
     根据 加密种子获取 解密后的助记词
     */
    vector<string> getMnemonicCodeFromBtWallet(BtSeed btSeed, string password, NetParams netParams);
    
    /*
     一次创建一个地址
     */
    bool createWallet(string words, string password, NetParams netParams, BtWallet& bw);
    
    /*
     一次创建多种币种钱包
     */
    vector<BtWallet*> createWallets(string words, string password, vector<NetParams> netParamsList);
    
    /*
     修改密码
     */
    bool changePassword(BtSeed btSeed, string oldPassword, string newPassword, BtSeed& newBtSeed, NetParams netparams);
    
    /*
     创建签名交易
     */
    bool createSignTransaction(CreateSignTransactionParams* createSignTransactionParams, NetParams netParams, map<string, string>& resultMap);
    
    /*
     验证地址有效性
     */
    bool validateAddress(const string& address, NetParams netParams);

    /*
     发送token
     */
    bool getTokenTransferBinary(string destAddress, u256 value, vector<uint8_t>& encode);

    /*
     lbtc注册
     */
    bool getLbtcRegister(string address, string prikey, string name, NetParams netparams, vector<uint8_t>& encode);

    /*
     lbtc投票
     */
    bool getLbtcVote(string address, string prikey, vector<string> voteAddressList, NetParams netparams, vector<uint8_t>& encode);

    /*
     lbtc取消投票
     */
    bool getLbtcCancelVote(string address, string prikey, vector<string> voteAddressList, NetParams netparams, vector<uint8_t>& encode);
private:
    bool getBIP44Path(KeyPath keyPath, vector<ChildNumber>& path );
    bool getBIP44PathV2(KeyPath keyPath, vector<ChildNumber>& path);
private:
    static map<string, vector<ChildNumber> > BIP44Map;
    
    
};

#endif /* CommonCoinApi_hpp */
